package com.youlu.campus.common.utils;

/**
 * Created by zhuhuaiqi.
 *
 */
public class ValidatorUtils {

    /**
     * 由除空格、逗号、单双引号、反斜杠外的6-18位字符组成；字符必须包含字母、数字、符号中至少2种；
     */
    private static final String REGEX_PASSWORD = "^(?![0-9]+$)(?![a-zA-Z]+$)(?![`~!@#$%^&*()_+\\-=\\[\\];,./{}|:<>?]+$)[0-9A-Za-z`~!@#$%^&*()_+\\-=\\[\\];,./{}|:<>?]{6,18}$";

    public static boolean validatePassword(String password) {
        return password.matches(REGEX_PASSWORD);
    }

    /**
     * 1，不能全部是数字
     * 2，不能全部是字母
     * 3，必须是数字或字母
     *
     * 由除空格、逗号、单双引号、反斜杠外的6-18位字符组成；字符必须包含字母、数字、符号中至少2种；
     * 字符必须包含字母、数字、符号中至少2种
     *
     * @param args
     */
    public static void main(String[] args) {
        String regex = REGEX_PASSWORD;

        String value = "aaa";  // 长度不够
        System.out.println(value + ",result=" + value.matches(regex));

        value = "1111aaaa1111aaaaa";  // 太长
        System.out.println(value + ",result=" + value.matches(regex));

        value = "111111111"; // 纯数字
        System.out.println(value + ",result=" + value.matches(regex));

        value = "aaaaaaaaa"; // 纯字母
        System.out.println(value + ",result=" + value.matches(regex));

        value = "####@@@@#"; // 特殊字符
        System.out.println(value + ",result=" + value.matches(regex));

        value = "~`)(}{@#%$&^*+=-_;:.?|><"; //特殊字符
        System.out.println(value + ",result=" + value.matches(regex));

        value = "1111aaaa";  // 数字字母组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "aaaa1111"; // 数字字母组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "aa1111aa";    // 数字字母组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "11aaaa11";    // 数字字母组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "aa11aa11"; // 数字字母组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "111@!@#$%"; // 数字特殊字符组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "bbcc@!@#$%-"; // 字母特殊字符组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "bbcc@!?/"; // 字母特殊字符组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "@!?/bbcc"; // 字母特殊字符组合
        System.out.println(value + ",result=" + value.matches(regex));

        value = "``````1111"; // 字母特殊字符组合
        System.out.println(value + ",result=" + value.matches(regex));
    }
}
